package gorotine

import (
	"fmt"
	"time"
)

func Loop() {
	for i := 1; i < 11; i++ {
		time.Sleep(time.Millisecond * 10)
		fmt.Printf("%d,", i)
	}
}

//定义一个公共变量
var ChanInt chan int = make(chan int, 10)

func Send() {
	ChanInt <- 1
	time.Sleep(time.Second * 1)
	ChanInt <- 2
	time.Sleep(time.Second * 1)
	ChanInt <- 3
	time.Sleep(time.Second * 1)
}

//接受chan 中的数据
func Receive() {
	num := <-ChanInt
	fmt.Println("num:", num)
	num1 := <-ChanInt
	fmt.Println("num:", num1)
	num2 := <-ChanInt
	fmt.Println("num:", num2)
}
